﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.SqlClient;
using System.Data;
namespace DAO
{
    public class TKKyHanDA
    {
         public static TKKyHan GetByID(int maID)
        {
            TKKyHan loai = null;
            SqlConnection cn = DataProvider.Connect();
            SqlCommand cmd = new SqlCommand("Proc_TKKyHan_GetById", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@maLoai", maID));
            SqlDataReader dataReader = cmd.ExecuteReader();
            if (dataReader.Read())
            {
                loai = new TKKyHan();
                loai.MaLoai = maID;
                loai.TenTK = Convert.ToString(dataReader["Ten"]);
                loai.LastUpdate = Convert.ToDateTime(dataReader["LastUpdate"]);               
            }
            cn.Close();
            return loai;
        }
        
    }
}
